--TEST--
resource MySQLndUhConnection::stmtInit(resource $connection)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
	require_once('config.inc');

	class proxy extends MySQLndUhConnection {
		public function stmtInit($res) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			var_dump($ret = parent::stmtInit($res));
			return $ret;
		}
	}

	class proxy2 extends MySQLndUhConnection {
		public function stmtInit($res) {
			return 0;
		}
	}

	function test_stmt($stmt, $offset) {
		if (!$stmt->prepare("SELECT 1 FROM DUAL")) {
			printf("[%03d] [%d] %s\n", $offset, $stmt->errno, $stmt->error);
			return false;
		}
		$col1 = NULL;
		$stmt->bind_result($col1);
		$stmt->execute();
		printf("[%03d] Results:\n", $offset);
		while ($row = $stmt->fetch())
			var_dump($col1);
		$stmt->close();
	}

	$conn = mysqlnd_uh_test\connect::mysqli();
	$stmt = mysqli_stmt_init($conn);
	test_stmt($stmt, 1);
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy());
	$stmt = mysqli_stmt_init($conn);
	test_stmt($stmt, 2);

	mysqlnd_uh_set_connection_proxy(new proxy2());
	$stmt = mysqli_stmt_init($conn);
	test_stmt($stmt, 3);


	print "done!";
?>
--EXPECTF--
[001] Results:
int(1)
proxy::stmtInit(array (
  0 => NULL,
))
resource(%d) of type (MySQLnd Prepared Statement (internal only - you must not modify it!))
[002] Results:
int(1)

Warning: mysqli_stmt_init(): (MySQLnd User Handler) You either have not called the appropriate method from the MySQLndUhConnection class or you are not returning the return value you got from it. Wrong results, errors and even crashes may happen! in %s on line %d

Fatal error: Call to a member function prepare() on a non-object in %s on line %d